#define _CRT_SECURE_NO_WARNINGS
int bin_search(int arr[], int left, int right, int key)
{
	int mid = 0;
	int i = -1;
	while (left <= right)
	{
		mid = (left + right) / 2;
		if (arr[mid] > key)
		{
			right = mid;
		}
		else if (arr[mid] < key)
		{
			left = mid;
		}
		else 
			return mid;
		if (key > arr[right] || key < arr[left])
		{
			return i;
		}
	}
	
}